package cn.lingyangwl.agile.pay.pay.factory;

import cn.lingyangwl.agile.pay.pay.model.bo.IClientWrapper;
import cn.lingyangwl.agile.pay.pay.model.bo.WxServiceWrapper;
import cn.lingyangwl.agile.pay.pay.model.params.IsvParams;
import cn.lingyangwl.agile.pay.pay.model.params.IsvsubMchParams;
import cn.lingyangwl.agile.pay.pay.model.params.NormalMchParams;
import cn.lingyangwl.agile.pay.pay.model.params.wxpay.WxpayIsvParams;
import cn.lingyangwl.agile.pay.pay.model.params.wxpay.WxpayIsvsubMchParams;
import cn.lingyangwl.agile.pay.pay.model.params.wxpay.WxpayNormalMchParams;
import cn.lingyangwl.agile.pay.constant.IfCodeEnum;
import com.alibaba.fastjson2.JSONObject;
import org.springframework.stereotype.Service;

/**
 * @author shenguangyang
 */
@Service
public class WxPayFactory extends AbstractPayFactory {

    @Override
    public IfCodeEnum getIfCode() {
        return IfCodeEnum.WXPAY;
    }

    @Override
    public IClientWrapper buildClientWrapper(IsvParams isvParams) {
        return WxServiceWrapper.buildWxServiceWrapper(isvParams);
    }

    @Override
    public IClientWrapper buildClientWrapper(NormalMchParams normalMchParams) {
        return WxServiceWrapper.buildWxServiceWrapper(normalMchParams);
    }

    @Override
    public IsvParams buildIsvParams(String paramsStr) {
        return JSONObject.parseObject(aesCrypto.decrypt(paramsStr), WxpayIsvParams.class);
    }

    @Override
    public NormalMchParams buildNormalMchParams(String paramsStr) {
        return JSONObject.parseObject(aesCrypto.decrypt(paramsStr), WxpayNormalMchParams.class);
    }

    @Override
    public IsvsubMchParams buildIsvsubMchParams(String paramsStr) {
        return JSONObject.parseObject(paramsStr, WxpayIsvsubMchParams.class);
    }
}
